package com.jhg.drgclinicalpathway.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jhg.drgclinicalpathway.domain.PathTplData;
import com.jhg.drgclinicalpathway.domain.PathTplMeta;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface PathTplDataDao extends BaseMapper<PathTplData> {
    @Select({"<script>" ,
            "select top 1 * from 路径模板数据 where 模板ID=#{tempId} and proType=#{lx} ORDER BY xh desc ",
            "</script>"})
    public List<PathTplData> getMaxxhBymbid(@Param("tempId") String tempId, @Param("lx") String lx);

    @Select({"<script>" ,
            "select top 1 * from 路径模板数据 where 模板ID=#{tempId} and trim(objid)=#{objid} ",
            "</script>"})
    public List<PathTplData> getMaxxhBymbObjid(@Param("tempId") String tempId, @Param("objid") String objid);
    @Update({"<script>",
            "update 路径模板数据 set xh=xh+1 where 模板ID=#{tempId} and xh>#{xh}" ,
            "</script>"})
    public  int updateXh(@Param("tempId") String tempId, @Param("xh") int xh);

    @Select("<script>" +
            " select id as tempId,名称 as tempName from 路径模板 where 路径ID in (select 路径ID from 路径模板  where id in " +
            "<foreach collection='ls' open='(' close=')' item='item' index='i' separator=','>"+
                "#{item.tempId}"+
            "</foreach>"+
            ")</script>")
    public List<Map<String, Object>> getTempids(@Param("ls") List<Map<String, Object>> ls);
}
